<?php
/*前台父级控制器*/
namespace app\common\controller;

use think\Controller;

class IndexBase extends Controller
{
	protected function _initialize()
    {
        parent::_initialize();
        //获取网站配置信息
        $web = db('system')->where(['name'=>'site_config'])->value('value');
        $nav = $this->getMenu(1);//导航
        $this->assign([
        	'web'=>unserialize($web),
            'nav'=>$nav,
        ]);
    }
    protected function getMenu($nav_cid)
    {
        $menu = db('nav')->where(['nav_cid'=>$nav_cid,'status'=>1])->order(['sort' => 'DESC', 'id' => 'ASC'])->select();

        $menu = !empty($menu) ? list_to_tree($menu,'id','pid','child') : [];
        return $menu;
    }
}